A bunch of busy-work in coce that approximarly never is actually run but solely for...
authorRobert Lipe <robertlipe@gpsbabel.org>
Mon, 9 Dec 2019 08:26:50 +0000 (02:26 -0600)
committerRobert Lipe <robertlipe@gpsbabel.org>
Mon, 9 Dec 2019 08:26:50 +0000 (02:26 -0600)
arcdist.cc
cet_util.cc
energympro.cc
jeeps/gpscom.cc

index 749efdef4d05108331979abd7604d6fe0ea5a409..328719aac0cd4b80c9f1d161c5de5750f33a8689 100644 (file)
@@ -27,6 +27,7 @@
 #include <cmath>
 #include <cstdio>
 #include <cstdlib> // strtod
+#include <src/core/logging.h>
 
 #if FILTERS_ENABLED
 #define MYNAME "Arc filter"
@@ -60,6 +61,13 @@ void ArcDistanceFilter::arcdist_arc_disp_wpt_cb(const Waypoint* arcpt2)
           prjlon = arcpt2->longitude;
           frac = 1.0;
         } else {
+          if (waypointp == nullptr) {
+            Fatal() << "Internal error. Attempt to project through a waypoint that doesn't exist";
+          }
+          if (arcpt1 == nullptr) {
+            Fatal() << "Internal error: Attempt to project waypoint without predecessor";
+          }
+
           dist = linedistprj(arcpt1->latitude,
                              arcpt1->longitude,
                              arcpt2->latitude,
index e802cfedb664b55e7dc0f025fd430726cace3c52..0e6970e7fce0c92321d2965d7fad78e6185b52e8 100644 (file)
@@ -82,7 +82,7 @@ cet_str_any_to_any(const char* src, const cet_cs_vec_t* src_vec, const cet_cs_ve
 static signed int
 cet_cs_alias_qsort_cb(const void* a, const void* b)
 {
-  const cet_cs_alias_t* va = (const cet_cs_alias_t*) a;
+  const auto* va = (const cet_cs_alias_t*) a;
   const cet_cs_alias_t* vb = (const cet_cs_alias_t*) b;
   return case_ignore_strcmp(va->name, vb->name);
 }
@@ -219,7 +219,7 @@ cet_find_cs_by_name(const QString& name)
 
   while (i <= j) {
     int a = (i + j) >> 1;
-    cet_cs_alias_t* n = &cet_cs_alias[a];
+    auto n = &cet_cs_alias[a];
     int x = case_ignore_strcmp(name, n->name);
     if (x == 0) {
       return n->vec;
@@ -376,7 +376,7 @@ cet_convert_string(const QString& str)
 static void
 cet_convert_waypt(const Waypoint* wpt)
 {
-  Waypoint* w = const_cast<Waypoint*>(wpt);
+  auto* w = const_cast<Waypoint*>(wpt);
 
   if ((cet_output == 0) && (w->wpt_flags.cet_converted != 0)) {
     return;
@@ -398,7 +398,7 @@ cet_convert_waypt(const Waypoint* wpt)
 static void
 cet_convert_route_hdr(const route_head* route)
 {
-  route_head* rte = const_cast<route_head*>(route);
+  auto* rte = const_cast<route_head*>(route);
 
   if ((cet_output == 0) && (rte->cet_converted != 0)) {
     return;
index 4b4dda1671f5a915b88a96a45134fd78bbab3bc4..dd133c078fe35e842d5194e918cf1ea56ba8c94d 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "defs.h"
 #include <QtCore/QDebug>
-#include <climits>
 
 #define MYNAME "energympro"
 
@@ -126,11 +125,11 @@ struct tw_lap {
 static void
 read_point(route_head* gpsbabel_route,gpsbabel::DateTime& gpsDateTime)
 {
-  tw_point point;
+  tw_point point{};
   gbfread(&point,sizeof(tw_point),1,file_in);
   if (global_opts.debug_level > 1) {
-    printf("Point: lat:%8d long:%8d alt:%8d ",point.Latitude,point.Longitude,point.Altitude);
-    printf("speed:%6d dist:%5d time:%5d Status:%1d", point.Speed,point.IntervalDist,point.lntervalTime,point.Status);
+    printf("Point: lat:%8u long:%8u alt:%8d ",point.Latitude,point.Longitude,point.Altitude);
+    printf("speed:%6u dist:%5u time:%5d Status:%1u", point.Speed,point.IntervalDist,point.lntervalTime,point.Status);
     printf("HR:(%3d,%1d)", point.HR_Heartrate,point.HR_Status);
     printf("Speed:(%8d,%1d)", point.Speed_Speed,point.Speed_Status);
     printf("Cad:(%3d,%1d)", point.Cadence_Cadence, point.Cadence_Status);
@@ -151,7 +150,7 @@ read_point(route_head* gpsbabel_route,gpsbabel::DateTime& gpsDateTime)
   qint64 mSecsSinceEpoc = gpsbabeltime.toMSecsSinceEpoch();
   gpsbabeltime.setMSecsSinceEpoch(mSecsSinceEpoc-mSecsSinceEpoc%1000);
 
-  Waypoint* waypt = new Waypoint;
+  auto waypt = new Waypoint;
   waypt->latitude = (point.Latitude / 1000000.0);
   waypt->longitude = (point.Longitude / 1000000.0);
   waypt->altitude = point.Altitude;
@@ -182,7 +181,7 @@ read_point(route_head* gpsbabel_route,gpsbabel::DateTime& gpsDateTime)
 static void
 read_lap()
 {
-  tw_lap lap;
+  tw_lap lap{};
   gbfread(&lap,sizeof(tw_lap),1,file_in);
   if (global_opts.debug_level > 1) {
     printf("LAP: splitTime:%6ds TotalTime:%6ds LapNumber:%5d ",lap.splitTime/10,lap.TotalTime/10,lap.Number);
@@ -234,20 +233,20 @@ track_read()
 
   gbfseek(file_in, 0L, SEEK_END);
   gbfseek(file_in, -(int32_t)(sizeof(tw_workout)), SEEK_CUR);
-  tw_workout workout;
+  tw_workout workout{};
   workout.dateStart.Year = gbfgetc(file_in);
   workout.dateStart.Month = gbfgetc(file_in);
   workout.dateStart.Day = gbfgetc(file_in);
   workout.timeStart.Hour = gbfgetc(file_in);
   workout.timeStart.Minute = gbfgetc(file_in);
   workout.timeStart.Second = gbfgetc(file_in);
-  workout.TotalRecPt = gbfgetint16(file_in);
-  workout.TotalTime = gbfgetint32(file_in);
-  workout.TotalDist = gbfgetint32(file_in);
-  workout.LapNumber = gbfgetint16(file_in);
-  workout.Calory = gbfgetint16(file_in);
-  workout.MaxSpeed = gbfgetint32(file_in);
-  workout.AvgSpeed = gbfgetint32(file_in);
+  workout.TotalRecPt = gbfgetuint16(file_in);
+  workout.TotalTime = gbfgetuint32(file_in);
+  workout.TotalDist = gbfgetuint32(file_in);
+  workout.LapNumber = gbfgetuint16(file_in);
+  workout.Calory = gbfgetuint16(file_in);
+  workout.MaxSpeed = gbfgetuint32(file_in);
+  workout.AvgSpeed = gbfgetuint32(file_in);
   workout.MaxHeart = gbfgetc(file_in);
   workout.AvgHeart = gbfgetc(file_in);
 
index 547c4487a124a6efb460883a1af8960d6eb2c2b6..ed8b445b806e9185eab343cbfbae1c754c2e818c 100644 (file)
@@ -1255,7 +1255,9 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32
         trk_idx = strtoul(ctk[j]->trk_ident, nullptr, 0);
         continue;
       }
-
+      if (wpt[i] == nullptr || ctk[j] == nullptr) {
+        fatal("Internal error in GPS_Command_Send_Track_As_Course");
+      }
       dist = gcgeodist(wpt[i]->lat, wpt[i]->lon, ctk[j]->lat, ctk[j]->lon);
       if (dist < min_dist) {
         min_dist = dist;
@@ -1264,6 +1266,9 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32
       }
     }
 
+    if (wpt[i] == nullptr) {
+      fatal("Internal error in GPS_Command_Send_Track_As_Course: no wpt");
+    }
     cpt[i+n_cpt] = GPS_Course_Point_New();
     strncpy(cpt[i+n_cpt]->name, wpt[i]->cmnt,
             sizeof(cpt[i+n_cpt]->name) - 1);